package com.sxjh.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.sxjh.entity.UnloadLog;
import com.sxjh.entity.param.UnloadLogDayParam;
import com.sxjh.entity.param.UnloadLogListParam;
import com.sxjh.entity.result.UnloadLogDayResult;
import com.sxjh.entity.result.UnloadLogListResult;
import com.sxjh.entity.result.UnloadLogWeighResult;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.PathVariable;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * 卸货记录  Mapper 接口
 * </p>
 *
 * @author zixin
 * @since 2021-06-06
 */
public interface UnloadLogMapper extends BaseMapper<UnloadLog> {

    List<UnloadLogListResult> list(UnloadLogListParam param);

    List<UnloadLogDayResult> day(UnloadLogDayParam param);

    @Select("select ifnull(max(right(`number`, 3)),0) as count from it_unload_log iul where created_at > #{localDate}")
    Integer serial(LocalDate localDate);

    // 根据打印编号查询打印数据
    UnloadLogWeighResult getPrint(@Param("number") String number);

    /**
     * 自定义分页
     *
     * @param convert2iPage
     * @param convert2Wrapper
     * @return
     */
    IPage<UnloadLogListResult> page(IPage<UnloadLogListResult> convert2iPage, @Param(Constants.WRAPPER) Wrapper<UnloadLogListResult> convert2Wrapper);
}
